hackerrank sherlock and array solution in java